package leetcode.code1784;

import leetcode.IDebug;

public class Solution2 implements IDebug {

	public boolean checkOnesSegment(String s) {
		int len = s.length();
		char[] cs = s.toCharArray();
		if (len == 2) {
			return cs[1] == '0' ? false : cs[1] == cs[0];
		}
		int count = 0;
		for (int i = 2; i <= len; i++) {
			char cur = i < len ? cs[i] : '0';
			if (cur == '0' && cs[i - 1] == cs[i - 2] && cs[i - 1] == '1') {
				count++;
				if (count == 2) {
					return false;
				}
			}
		}
		return count == 1;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
